# Matplotlib

#Import
import matplotlib.pyplot as plt
import numpy as np
import csv

# 1
plt.plot([1,2,4,9,16,25,36,1])
plt.show()

# 2 & 3
plt.plot([7,8,9,10,11,12,13,14,15,16,17,18],[10, 10, 10, 30, 20, 25, 30, 35, 70, 75, 80, 10])
plt.axis([7,18,0,100])
# a
plt.grid(True)
# b
plt.title('Processorbelasting')
# c
plt.xlabel('Tijd')
# d
plt.ylabel('Percentage')
# e
x = np.arange(1, 5)
plt.plot(x,color='blue',label='Processorbelasting')
plt.legend(loc='upper left')
# g
plt.annotate('Wat gebeurt hier?!', xy=(17,80), xytext=(15,40),arrowprops=dict(facecolor='black'))
plt.show()

# 4
labels = 'Win7','Vista','NT*','WinXP','Linux','Mac','Mobile'
fracs = [56.8,3.0,1.8,22.1,4.8,9.2,1.8]
_, _, autotexts = plt.pie(fracs,labels=labels,autopct='%1.1f%%')
for autotext in autotexts:
    autotext.set_color('white')
plt.axis('equal')
plt.show()

# 5
f = open('logfile.csv','rt')
data = []
try:
    reader = csv.reader(f)
    for row in reader:
        data.append(float(row[1]))
finally:
    f.close()
plt.plot(data)
plt.show()